# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2021年12月23日
"""
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_excel('../source/TB - 7.6.xls', parse_dates=['订单付款时间'])
df1 = df[['订单付款时间', '买家实际支付金额']]
df1 = df1.set_index('订单付款时间')
plt.rcParams['font.sans-serif'] = ['SimHei']
# 按年统计数据
df_y = df1.resample('AS').sum().to_period('A')
# 按季度统计
df_q = df1.resample('Q').sum().to_period('Q')
# 绘制子图
fig = plt.figure(figsize=(8, 3))
ax = fig.subplots(1, 2)
df_y.plot(subplots=True, ax=ax[0])
df_q.plot(subplots=True, ax=ax[1])
plt.subplots_adjust(top=0.95, bottom=0.2)
plt.show()

print(df_q)
